from otree.api import Currency as c, currency_range
from ._builtin import Page, WaitPage
from .models import Constants


class MyPage(Page):
    pass


class WaitOther(WaitPage):
    title_text = "等待页面"
    body_text = "请等待其他玩家完成测试。之后一起进行下一阶段的任务。"
    after_all_players_arrive = 'set_payoffs'


class Results(Page):
    pass


class question(Page):
    form_model = 'player'
    form_fields = ['sex', 'is_economics_and_management_major', 'is_join_economics_experience',
                   'nation', 'city_or_countryside', 'is_party_member', 'is_education_loan', 'is_part_time_job',
                   'is_party_member', 'is_education_loan', 'is_part_time_job', 'do_more', 'is_guilt',
                   'group_identification_1', 'group_identification_2',
                   'scene_question1', 'scene_question2', 'scene_question3_1', 'scene_question3_2', 'scene_question3_3',
                   'scene_question4'
        , 'time_error', 'is_hard_work', 'hard_to_common_point', 'willing_to_give_in', 'easy_accept_proposal',
                   'result_satisfied', 'difficulty_view_1', 'difficulty_view_2', 'difficulty_view_3',
                   'rationality_view', ]


class Survey2(Page):
    form_model = 'player'
    form_fields = ['B_q1', 'B_q2', 'B_q3', 'B_q4', 'B_q5', 'B_q6', 'B_q7', 'B_q8', 'B_q9', 'B_q10',
                   'B_q11', 'B_q12', 'B_q13', 'B_q14', 'B_q15', 'B_q16', 'B_q17', 'B_q18', 'B_q19', 'B_q20',
                   'B_q21', 'B_q22']

    def vars_for_template(self):
        list = []
        q_list = []
        q_list.append('我获得100.00,对方获得 100.00')
        q_list.append('我获得88.80,对方获得111.20')
        q_list.append('我获得88.40,对方获得111.60')
        q_list.append('我获得87.80,对方获得112.20')
        q_list.append('我获得87.20,对方获得112.80')
        q_list.append('我获得86.40,对方获得113.60')
        q_list.append('我获得85.80,对方获得114.20')
        q_list.append('我获得84.80,对方获得115.20')
        q_list.append('我获得83.80,对方获得116.20')
        q_list.append('我获得82.80,对方获得117.20')
        q_list.append('我获得81.40,对方获得118.60')
        q_list.append('我获得78.40,对方获得121.60')
        q_list.append('我获得77.20,对方获得122.80')
        q_list.append('我获得76.20,对方获得123.80')
        q_list.append('我获得73.60,对方获得126.40')
        q_list.append('我获得70.60,对方获得129.40')
        q_list.append('我获得66.60,对方获得133.40')
        q_list.append('我获得57.00,对方获得143.00')
        q_list.append('我获得54.40,对方获得145.60')
        q_list.append('我获得44.40,对方获得155.60')
        q_list.append('我获得28.60,对方获得171.40')
        q_list.append('我获得2.00,对方获得198.00')

        return dict(
            # q_list='我获得2，对方获得2',
            # same_question=q_list
            q_list=q_list,
            same_question='我获得40.00，对方获得40.00'
        )


class Survey3(Page):
    form_model = 'player'
    form_fields = ['C_q1', 'C_q2', 'C_q3', 'C_q4', 'C_q5', 'C_q6', 'C_q7', 'C_q8', 'C_q9', 'C_q10',
                   'C_q11', 'C_q12', 'C_q13', 'C_q14', 'C_q15', 'C_q16', 'C_q17', 'C_q18', 'C_q19', 'C_q20',
                   'C_q21', 'C_q22']

    def vars_for_template(self):
        list = []
        q_list = []
        for i in range(22):
            q_list.append('我获得{},对方获得{}'.format(i * 10, i * 10))
        return dict(
            q_list=q_list,
            same_question='我获得200，对方获得0'
        )


# class Cake_cut(Page):
#     form_model = 'player'
#     form_fields = ['cut_value']
#     def is_displayed(self):
#         return self.player.id_in_group == 1 and self.round_number <= 5

page_sequence = [WaitOther, MyPage, Survey2, Survey3, question, Results]
